package com.gang.mars.basic.map;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;

/**
 * @author gang.chen
 * @Date 2022/8/16 9:00
 */
public class TestBanana03 {

    public static void main(String[] args) {
        List<String> languages = new ArrayList<>();
        languages.add("java");
        languages.add("js");
        languages.add("vb");

        Map<String,Integer> map = new ConcurrentHashMap();
        map.put("java", 1);

        languages.forEach( language -> {
            Integer integer = map.computeIfAbsent(language, (String key) -> {
                //System.out.println("key=" + key);
                Integer value = map.get(key);
                value = (value == null) ? 1 : value + 1;
                return value;
            });
            System.out.println(integer);
        });
        System.out.println(map);
    }
}
